/* app未登录引导页 */

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hcc/pages/login/login_page.dart';
import 'package:flutter_hcc/widget/outline_button.dart';

class BaseRootPage extends StatefulWidget {
  @override
  _BaseRootPagesState createState() => _BaseRootPagesState();
}

class _BaseRootPagesState extends State<BaseRootPage> {
  @override
  Widget build(BuildContext context) {
    /// 隐藏状态栏
    SystemChrome.setEnabledSystemUIOverlays([]);
    // 状态栏显示
    // SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
    return Container(
        decoration: BoxDecoration(
            image: DecorationImage(
          //image: NetworkImage('https://img.zcool.cn/community/0372d195ac1cd55a8012062e3b16810.jpg'),
          image: ExactAssetImage("images/002.jpg"),
          fit: BoxFit.cover,
        )),
        child: Scaffold(
            backgroundColor: Colors.transparent, //把scaffold的背景色改成透明
            resizeToAvoidBottomInset: true,
            appBar: AppBar(
              backgroundColor: Colors.transparent, //把appbar的背景色改成透明
              elevation: 0, //appbar的阴影
              // title: Text("登录基础页"),
            ),
            body: Container(
              alignment: Alignment.bottomCenter,
              child: Stack(
                alignment: AlignmentDirectional.center,
                children: [
                  Container(
                    height: 118,
                    color: Color(0x9AFFFFFF),
                  ),
                  BaseButton("进入Hik Connect commercial", modalLoginPage)
                ],
              ),
            )));
  }

  modalLoginPage() {
    showModalBottomSheet(
      isScrollControlled: true,
      context: context,
      backgroundColor: Colors.transparent,
      builder: (BuildContext modalContext) {
        return SingleChildScrollView(
          child: Container(
            height: 300,
            child: Stack(
              children: <Widget>[
                Container(
                  //顶部透明，为了展示圆角
                  height: 25,
                  width: double.infinity,
                  color: Colors.transparent,
                ),
                Container(
                  // 内容撑起
                  height: 300,
                  width: double.infinity,
                  child: Navigator(
                    initialRoute: '/',
                    onGenerateRoute: (RouteSettings settins) {
                      WidgetBuilder builder;

                      switch (settins.name) {
                        case '/':
                          builder = (modalContext) => AMLoginPage(context);
                          break;
                      }
                      return MaterialPageRoute(builder: builder);
                    },
                  ),
                  decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(25),
                      topRight: Radius.circular(25),
                    ),
                  ),
                ),
              ],
            ),
          ),
        );
      },
    );
  }
}
